You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added validation for range and numeric field settings in the form builder: invalid configs (e.g., min ≥ max, non-positive or oversized step) now show clear error messages and highlight affected fields.
Improved field-type/ID detection to make validations more reliable.
Validation utilities are now exposed so other admin tools can trigger or reuse these checks.
Too much diff to scan? Review this PR in Change Stack to start with the highest-impact changes.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: db5f5cd6-6b5d-4896-b8a6-08acf8a95400
📥 Commits
Reviewing files that changed from the base of the PR and between 382a5bc and 6573fc5.
📒 Files selected for processing (2)
js/formidable_admin.js
js/src/admin/settings/validateRangeSettings.js
📝 Walkthrough
Walkthrough
Adds client-side validation for range and step settings: a generic validator that shows errors in the info modal and restores focus, range/step-specific checks (min < max, step bounds), builder wiring to run validations on change, and a public API under frmAdminBuild.settings.validate.
Changes
Range Settings Validation
Layer / File(s)
Summary
Generic Field Validation Framework js/src/admin/settings/validateField.js
validateField(field, getError) runs a validation callback, shows the info modal on error, toggles the frm_invalid_field CSS class, and restores focus after modal dismissal via focusFieldOnModalDismiss.
Range and Step Validators js/src/admin/settings/validateRangeSettings.js
getRangeSettingsDefaults derives numeric defaults with frm_range_settings_defaults filter support. validateNumberRangeSetting enforces min < max for number-range fields. validateStepSetting enforces step > 0 and that step ≤ (max - min). validateRangeSettings runs both and applies frm_validate_range_settings.
Builder Integration and Public API js/src/admin/admin.js
Imports validation utilities, invokes validateRangeSettings(target) in handleBuilderChangeEvent, and exposes validation functions under frmAdminBuild.settings.validate for external use.
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
🐰 New validators jump and play,
min and max kept in their place,
steps counted true, not astray,
modals blink and return my gaze,
builder hums with validation grace.
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
✅ Passed
The title accurately describes the main change—adding validation utilities to fix number field validation appearing when min/max values are empty, which is reflected throughout the changeset.
Docstring Coverage
✅ Passed
Docstring coverage is 88.89% which is sufficient. The required threshold is 80.00%.
Linked Issues check
✅ Passed
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
✅ Passed
Check skipped because no linked issues were found for this pull request.
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches📝 Generate docstrings
Create stacked PR
Commit on current branch
🧪 Generate unit tests (beta)
Create PR with unit tests
Commit unit tests in branch fix-number-validation-popup
⚔️ Resolve merge conflicts
Resolve merge conflict in branch fix-number-validation-popup
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (3)
js/src/admin/admin.js (2)
8458-8463: Builder change handler now conditionally runs range/step validation
Hooking validateNumberRangeSetting(target) and validateStepSetting(target) from handleBuilderChangeEvent behind ! frmGlobal.proIsConnected looks safe: both helpers guard on the element’s context (.frm-number-range / .frm-step) and will no-op for unrelated changes, so the extra work on the builder change stream is minimal while avoiding duplicate validation when Pro is connected.
If you want to tighten this further later, you could short‑circuit on target.closest('.frm-number-range, .frm-step') before calling either validator to avoid two function calls for clearly unrelated inputs.
11170-11180: Public frmAdminBuild.settings.validate API looks good; fill in @since
Exposing validateField, getRangeSettingsDefaults, validateNumberRangeSetting, and validateStepSetting under frmAdminBuild.settings.validate is a reasonable and coherent namespace, and aligns with how other helpers are surfaced from this module. The only nit is the JSDoc @since x.x placeholder above it; consider replacing this with the actual release version so downstream consumers know when this API became available.
51-120: Consider extracting common field lookup pattern.
Both validateNumberRangeSetting and validateStepSetting share a similar pattern for retrieving singleSettings, fieldId, and related input elements. Consider extracting this into a shared helper function to reduce duplication.
Example refactoring:
/** * Gets common field validation context. */functiongetFieldContext(field,containerClass){if(!field.closest(containerClass)){returnnull;}constsingleSettings=field.closest('.frm-single-settings');constfieldId=getFieldId(singleSettings);returnfieldId ? { singleSettings, fieldId } : null;}exportfunctionvalidateNumberRangeSetting(field){constcontext=getFieldContext(field,'.frm-number-range');if(!context){return;}const{ singleSettings, fieldId }=context;// ... rest of validation}
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 6d6fde5 and 43eed37.
⛔ Files ignored due to path filters (1)
js/formidable_admin.js.map is excluded by !**/*.map, !**/*.map
3868-3868: LGTM. The proIsConnected addition correctly exposes the Pro connection status to frontend validation logic. The implementation gates number field range and step validation to run only when Pro is disconnected, with proper handling of empty min/max values via default values. The validation logic is sound and works correctly in both connected and disconnected states.
js/src/admin/admin.js (1)
4-8: New validation imports are consistent and correctly scoped
The new require calls for validateField, getRangeSettingsDefaults, validateNumberRangeSetting, and validateStepSetting match the existing CommonJS pattern in this file and are only used where needed; no issues from a bundling or scoping perspective.
js/src/admin/settings/utils.js (1)
11-30: LGTM! Good use of optional chaining.
Both utility functions properly handle null/undefined inputs using optional chaining, making them safe to call in various contexts without explicit null checks by the caller.
The validation logic properly addresses the PR objective by using fallback defaults (0 for min, 9999999 for max) when fields are empty. This ensures validation doesn't trigger incorrectly when min/max values are not provided, while still catching actual invalid entries.
104-119: LGTM! Step validation logic is sound.
The validation correctly ensures step is positive and doesn't exceed the maximum value, while gracefully handling empty inputs using defaults.
We reviewed changes in b7cd07c...b3ae6ed on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.
Some issues found as part of this review are outside of the diff in this pull request and aren't shown in the inline review comments due to GitHub's API limitations. You can see those issues on the DeepSource dashboard.
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
The reason will be displayed to describe this comment to others. Learn more.
Function 'validateNumberRangeSetting' expected no return value
Any code paths that do not have explicit returns will return undefined. It is recommended to replace any implicit dead-ends that return undefined with a return null statement.
The reason will be displayed to describe this comment to others. Learn more.
Function 'validateStepSetting' expected no return value
Any code paths that do not have explicit returns will return undefined. It is recommended to replace any implicit dead-ends that return undefined with a return null statement.
The reason will be displayed to describe this comment to others. Learn more.
Function 'validateStepSetting' expected no return value
Any code paths that do not have explicit returns will return undefined. It is recommended to replace any implicit dead-ends that return undefined with a return null statement.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pro PR
https://github.com/Strategy11/formidable-pro/pull/6137
Summary by CodeRabbit